package com.his.benchwork.service.Imp;

import com.his.benchwork.dao.BenchWorkEmpMapper;
import com.his.benchwork.entity.BenchWorkEmp;
import com.his.benchwork.entity.BenchWorkEmps;
import com.his.benchwork.service.BenchWorkEmpService;
import com.his.benchwork.vo.BenchWorkEmpVo;
import com.xiao.common.util.BeanUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Author jzy
 * @Date 2020/3/13 14:33
 * @Version 1.0
 */
@Service
public class BenchWorkEmpServiceImpl implements BenchWorkEmpService {

    @Resource
    private BenchWorkEmpMapper benchWorkEmpMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<BenchWorkEmps> selectBenchWorkEmpList(BenchWorkEmpVo benchWorkEmpVo) {
        return benchWorkEmpMapper.select_emp(benchWorkEmpVo.getBenchid());
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addBenchWorkEmp(List<BenchWorkEmpVo> benchWorkEmpVoList) {
        for(BenchWorkEmpVo benchWorkEmpVo:benchWorkEmpVoList){
            BenchWorkEmp benchWorkEmp = BeanUtil.copyBean(benchWorkEmpVo,BenchWorkEmp.class);
            benchWorkEmp.setUpdatedate(new Date());
            benchWorkEmpMapper.add_emp(benchWorkEmp);
        }

    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteBenchWorkEmp(BenchWorkEmpVo benchWorkEmpVo) {
        BenchWorkEmp benchWorkEmp = BeanUtil.copyBean(benchWorkEmpVo,BenchWorkEmp.class);
        benchWorkEmpMapper.delete_emp(benchWorkEmp);
    }
}
